<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://unpkg.com/vue@next"></script>

    <title>Document</title>
</head>
<body>
    <div id="conditional-rendering">
        <span v-if="seen">哦豁</span>
        <button v-on:click="hideMessage">{{ button }}</button>
    </div>

    <script type="text/javascript">
        const ConditionalRendering = {
            data() {
                return {
                    seen: true,
                    button: "隐藏"
                }
            },
            methods: {
                hideMessage() {
                    if(this.seen){
                        this.seen = false
                        this.button = "显示"
                    }else{
                        this.seen = true
                        this.button = "隐藏"
                    }
                }
            }
        }

        Vue.createApp(ConditionalRendering).mount('#conditional-rendering')

    </script>
</body>
</html>